<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .hexagon {
            position: relative;
            width: 100px;
            height: 50px;
            margin: 50px auto;
            background-color: #333;
            border-left: 50px solid white;
            border-right: 50px solid white;
        }

        .hexagon::before,
        .hexagon::after {
            content: '';
            position: absolute;
            width: 0;
            border-style: solid;
            border-color: transparent;
        }

        .hexagon::before {
            top: -50px;
            left: 0;
            border-bottom: 50px solid #333;
            /* 六边形的颜色 */
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
        }

        .hexagon::after {
            bottom: -50px;
            left: 0;
            border-top: 50px solid #333;
            border-left: 50px solid transparent;
            border-right: 50px solid transparent;
        }
    </style>
</head>

<body>
    <div class="hexagon"></div>
</body>

</html>